home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / objtools / tltotext.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  84 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    tltotext -
  19.  *        Print a triangle list in text format.
  20.  *
  21.  *            Paul Haeberli - 1990
  22.  */
  23. #include "math.h"
  24. #include "stdio.h"
  25. #include "vect.h"
  26. #include "trilist.h"
  27. #include "lum.h"
  28.  
  29. main(argc,argv)
  30. int argc;
  31. char **argv;
  32. {
  33.     FILE *outf;
  34.     int blk;
  35.  
  36.     if(argc<2) {
  37.     fprintf(stderr, "usage: tltotext input.tl\n");
  38.     exit(1);
  39.     }
  40.     trilisttotext(argv[1]);
  41. }
  42.  
  43. float greyval(c)
  44. long c;
  45. {
  46.     float r, g, b;
  47.  
  48.     r = ((c>>0)&0xff)/255.0;
  49.     g = ((c>>8)&0xff)/255.0;
  50.     b = ((c>>16)&0xff)/255.0;
  51.     return LUM(r,g,b);
  52. }
  53.  
  54. cpacktov(c,v)
  55. long c;
  56. vect *v;
  57. {
  58.    v->x = ((c>>0)&0xff)/255.0;
  59.    v->y = ((c>>8)&0xff)/255.0;
  60.    v->z = ((c>>16)&0xff)/255.0;
  61. }
  62.  
  63. trilisttotext(name)
  64. char *name;
  65. {
  66.     int i, ntri;
  67.     trilisttri tri;
  68.     vect p0, p1, p2;
  69.     vect c0, c1, c2;
  70.  
  71.     ntri = tlopen(name);
  72.     fprintf(stdout, "ntri: %d\n",ntri);
  73.  
  74.     for(i=0; i<ntri; i++) {
  75.     tlread(&tri);
  76.     fprintf(stdout, "triangle %d:\n",i);
  77.     fprintf(stdout, "\tv0: %f %f %f 0x%08x:\n",tri.x0,tri.y0,tri.z0,tri.c0);
  78.     fprintf(stdout, "\tv1: %f %f %f 0x%08x:\n",tri.x1,tri.y1,tri.z1,tri.c1);
  79.     fprintf(stdout, "\tv2: %f %f %f 0x%08x:\n",tri.x2,tri.y2,tri.z2,tri.c2);
  80.  
  81.     }
  82.     tlclose();
  83. }
  84.